const path = require("path");
// const CircularDependencyPlugin = require("circular-dependency-plugin");

function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  css: {
    sourceMap: true // 开启 CSS source maps
  },
  configureWebpack: {
    plugins: []
  },
  chainWebpack(config) {
    // set svg-sprite-loader
    config.module
      .rule("svg")
      .exclude.add(resolve("src/assets/icons"))
      .end();
    config.module
      .rule("icons")
      .test(/\.svg$/)
      .include.add(resolve("src/assets/icons"))
      .end()
      .use("svg-sprite-loader")
      .loader("svg-sprite-loader")
      .options({
        symbolId: "icon-[name]"
      })
      .end();
    // set snap
    config.module
      .rule("Snap")
      .test(require.resolve("snapsvg/dist/snap.svg.js"))
      .use("imports-loader")
      .loader("imports-loader?this=>window,fix=>module.exports=0")
      .end();
    config.resolve.alias.set("snapsvg", "snapsvg/dist/snap.svg.js");
  }
};
